package com.multicampus.simplewiki.ctrl;

import com.multicampus.simplewiki.model.UserDAO;
import com.multicampus.simplewiki.model.User;

public class LoginManagerImpl implements LoginManager {
	UserDAO userDAO;
	
	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}
	
	public User validUser(User user){
		User findUser = userDAO.find(user.getId());
		
		if(findUser != null && findUser.isValidUser(user.getId(), user.getPassword()))
			return findUser;
		else
			return null;
	}
	
	public User find(String id){
		return userDAO.find(id);
	}

	public User addUser(User user) {
		return userDAO.add(user);
	}
}
